package com.runcode.web;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.runcode.entity.User;

import lombok.extern.slf4j.Slf4j;
@Slf4j
@RestController
public class ProducerController {

	
	@RequestMapping(value = "/hello")
	public String hello(String name, HttpServletRequest request ) {
		log.debug("req , {}" , request.getRequestURI());
		return "服务提供 producer： \t name ="+name ;
	}
	
	@RequestMapping(value = "/producer")
	public String producer(String name , HttpServletRequest request ) {
		log.debug("req , {}" , request.getRequestURI());
		return "调用服务提供 producer： \t name ="+name ;
	}
	
	@RequestMapping(value = "/producer/{name}")
	public String producers(@PathVariable String name , HttpServletRequest request ) {
		log.debug("req , {}" , request.getRequestURI());
		return "调用服务提供 producersssss： \t name ="+name ;
	}
	
	@RequestMapping(value = "/producer/user")
	public String user(User user, HttpServletRequest request ) {
		log.debug("req , {}" , request.getRequestURI());
		return "调用服务提供 producer-user 对象： \t name ="+user.toString() ;
	}
	
	@RequestMapping(value = "/producer/user/json")
	public String userJson(@RequestBody User user , HttpServletRequest request ) {
		log.debug("req , {}" , request.getRequestURI());
		return "调用服务提供 producer-usr json数据： \t name ="+user.toString() ;
	}
	
}
